home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / VideoToolbox 96.06.15 / VideoToolboxSources / GetTimeDateString.c < prev    next >
Text File  |  1995-07-27  |  772b  |  31 lines

  1. /*
  2. GetTimeDateString
  3.  
  4. Return a malloced string with the time and date in a nice format:
  5.     "5:03 PM, Monday, September 13, 1993"
  6. You may supply a calendar time, as returned by time(), or you may supply 0 to
  7. use the current time. 
  8.  
  9. HISTORY:
  10. 8/93    dhb,jms    wrote it, using Apple toolbox.
  11. 9/13/93    dgp    rewrote it using Standard C library.
  12. 9/16/93 dhb Fixed name of routine in PrintfExit.
  13. 7/16/94 dgp suppress leading zero in hours.
  14. */
  15. #include "VideoToolbox.h"
  16. #ifndef _TIME
  17.     #include <time.h>    /* Standard C library */
  18. #endif
  19.  
  20. char *GetTimeDateString(time_t t)
  21. {
  22.     char *s;
  23.     
  24.     s=malloc(64);
  25.     if(s==NULL)PrintfExit("GetTimeDateString: malloc(64) failed.\n");
  26.     if(t==0)t=time(NULL);
  27.     strftime(s,64,"%I:%M %p, %A, %B %d, %Y",localtime(&t));
  28.     if(s[0]=='0')strcpy(s,s+1);
  29.     return(s);
  30. }
  31.